

<template>

  <div class="addUserInfo" >
  
       <ViewTitle text="基础信息" />
     <div class="box1">
      <div>
        <span>门诊号:</span>
        <el-input
          size="mini"
          disabled
          v-model="thatF.yibao.selectItem.patient_no"
       >
        </el-input>
      </div>
         <div v-if="thatF.activeName=='2'">
        <span>医疗类别:</span>
        <div>
               <el-select   size="mini" v-model="params.med_type" placeholder="医疗类别" >
                <el-option
                  v-for="(item,index) in dict_med_type"
                  :key="'index1'+index"
                  :label="item.name"
                  :value="item.value"

                >
                </el-option>
              </el-select>
        </div>
    
      </div>
     
   
          <div  v-if="thatF.activeName=='2'">
        <span>诊断类别:</span>
        <div>
               <el-select   size="mini" v-model="params.diag_type" placeholder="诊断类别" >
                <el-option
                  v-for="(item,index) in dict_diag_type"
                  :key="'index1'+index"
                  :label="item.name"
                  :value="item.value"

                >
                </el-option>
              </el-select>
        </div>
    
      </div>
        <div v-if="thatF.activeName=='2'&&params.med_type==14">
            <span>慢特病类型:</span>
            <selectInput :thatF="this"></selectInput>
          
          </div>
     </div>
  
     <ViewTitle text="费用明细"  />

     <div  v-if="thatF.activeName=='1'"> 
          <el-table
          :data="fee_items"
          border
          style="width: 100%">
           <template v-for="(item, index) in $baseBai['yibaoInfo']['feiyong']">
           
             <el-table-column :width="item.width" v-if="item.prop == 'num'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <div >1</div>
                        </template>
              </el-table-column> 
                <el-table-column :width="item.width" v-else-if="item.prop == 'hosp_appr_flag'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.hosp_appr_flag" placeholder="审核标志" >
                            <el-option label="无须审批" value="0" ></el-option>
                            <el-option label="审批通过" value="1" ></el-option>
                            <el-option label="审批不通过" value="2" ></el-option>
                          </el-select>
                        </template>
              </el-table-column>
              
             <el-table-column v-else  :width="item.width"  :prop="item.prop" :label="item.label" > </el-table-column>
           </template>
           
        </el-table>

         
    </div>
       <div  v-if="thatF.activeName=='2'"> 
          <div class="box3" v-if="thatF.yibao.chargeDataArry.length>0" >
              
    
        <el-table
        style="width: 100%"
          border
          height="250"
            disabled
          :data="thatF.yibao.chargeDataArry"
         
        >

              <template v-for="(item,index) in $baseBai['yibaoInfo']['feiyongMX']"  >

                  <el-table-column :width="item.width" v-if="item.prop == 'rx_circ_flag'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.rx_circ_flag" placeholder="外购标志" >
                            <el-option label="是" value="1" ></el-option>
                            <el-option label="否" value="2" ></el-option>
                          </el-select>
                        </template>
              </el-table-column> 
               <el-table-column :width="item.width" v-else-if="item.prop == 'hosp_appr_flag'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.hosp_appr_flag" placeholder="审核标志" >
                            <el-option label="无须审批" value="0" ></el-option>
                            <el-option label="审批通过" value="1" ></el-option>
                            <el-option label="审批不通过" value="2" ></el-option>
                          </el-select>
                        </template>
              </el-table-column> 
                        
                   <el-table-column v-else :width="item.width"  :prop="item.prop" :label="item.label" :key="index"> </el-table-column>

              </template>
       
        </el-table>
      
    </div> 

         
    </div>
   

   
       
    <div class="buts">
          
           <el-button  class="butB_Add"  @click="save()">上传费用明细</el-button>
         
    </div>
  </div>
</template>
<script>
let t;
import selectInput from "@/components/select"
import jiesuan from "./jiesuan"
import ViewTitle from "@/forComponents/viewTitle/index.vue";
import { mapState,mapActions } from "vuex";
export default {
  props: ['thatF'],
  data() {
    return {
         setSelectInput:{
          placeholder:'慢特病类型',
          key:'mantebing',
          url:'getdict_dataGetChronicDiseaseDict',
         keyword:'',
         id:'',

        list:[
        
          {label:'慢特病编码',prop:'m_code'},
          {label:'内部编码',prop:'number'},
          {label:'疾病名称',prop:'name'},
        ],

      },
      params:{
        med_type:'11',
        diag_type:'1',
        
      },
     fee_items:[],
   
    };
  },
  mounted(){
    t=this;
    console.log("t.thatF.yibao.selectItem",t.thatF.yibao.selectItem)
    if(t.thatF.activeName=='1'){
       t.fee_items=t.thatF.yibao.selectItem.fee_items.map(v=>{
       return {
         ...v,
         hosp_appr_flag:'',
       }
     });
    }
    
  },
 
  methods: {
  
   
   
    save(){ 

   
      console.log("med_type",t.params.med_type)

      console.log("keyword",t.setSelectInput.keyword)
       console.log("code",t.setSelectInput.id)
       console.log("t.fee_items",t.fee_items)
        if(t.thatF.activeName=='1'){
            let d={
                patient_no:t.thatF.yibao.selectItem.patient_no,
                fee_items:t.fee_items.map(v=>{
                    return {
                    
                        amount:v.price,
                        num:1,
                        price:v.price,
                        med_list_codg:v.yb_code,
                        hosp_appr_flag:v.hosp_appr_flag,
                        medins_list_codg:v.number,
                        fill_number:v.fill_number,
                      
                    }
                }),
            }
           

           t['_API'].getregisterUploadFeeInfo(d).then(res=>{
               if(res.code==200){
                     this.$message({
                                  message: res.message,
                                  type: "success",
                                });
                                this.thatF.params.page=1;
                                this.thatF.getList()
               }
           })
        }else{
          if(!t.params.med_type){
              return t.$message.error('请选择医疗类别')
          }
           if(!t.params.diag_type){
              return t.$message.error('请选择诊断类别')
          }

            let d={
                patient_no:t.thatF.yibao.selectItem.patient_no,
                number:t.thatF.yibao.selectItem.number,
                med_type:t.params.med_type,
                visit_time:t.thatF.yibao.selectItem.created_at,
                disease_code:t.thatF.yibao.selectItem.medical_record.diagnosis[0].code,
                disease_name:t.thatF.yibao.selectItem.medical_record.diagnosis[0].name,
                diag_type:t.params.diag_type,
                fee_items:t.thatF.yibao.chargeDataArry.map(v=>{
                    return {
                        amount:v.amount, 
                        num:v.num?v.num:1,
                        price:v.price,
                        med_list_codg:v.yb_code,
                        medins_list_codg:v.number,
                        time:t.thatF.yibao.selectItem.created_at,
                        fill_number:v.fill_number,
                        rx_circ_flag:v.rx_circ_flag,
                        hosp_appr_flag:v.hosp_appr_flag,
                    }
                }),
            }
          if(t.params.med_type==14){
            d.chronic_code=t.setSelectInput.id;
            d.chronic_name=t.setSelectInput.keyword;
          }

           t['_API'].getclinic_feeUuploadFeeInf(d).then(res=>{
               if(res.code==200){
                     this.$message({
                                  message: res.message,
                                  type: "success",
                                });
                                this.thatF.params.page=1;
                                this.thatF.getList()
               }
           })
        }
          
    },
  

    
    
  },
    computed: {
    ...mapState({
         dict_med_type: state => state.dictBai.dict_med_type,
         dict_diag_type: state => state.dictBai.dict_diag_type,
    }),
  },
  components: {
    ViewTitle,
    jiesuan,
    selectInput,
    //  FormInfo
  },
};
</script>
<style lang='scss' scoped>
.addUserInfo {
padding: 0 4%;

  .box1 {
    display: flex;
    flex-wrap: wrap;
    padding: 20px 0;
    > div {
      position: relative;
      width: 33%;
      display: flex;
      align-items: center;
      // justify-content: center;
      margin-bottom: 20px;

      > span {
        display: inline-block;
        width: 100px;
      }
      /deep/ .el-input {
        width: 180px;
      }
    }
  }
  .box3 {
    margin: 20px 0;
  }

  .dukaBut {
    margin: 0px 0 20px;
  }
}

.buts{
    display: flex;
    align-items: center;
    justify-content: center;
    button{
        

    width: 200px;
    position: absolute;
    bottom: 28px;
    right: 45px;
    }
}


</style>